package org.sixtynine.stock.service.impl;

import java.util.Date;
import java.util.List;

import org.sixtynine.stock.dao.CustomerUpgradeDao;
import org.sixtynine.stock.dto.GridPramDTO;
import org.sixtynine.stock.dto.Page;
import org.sixtynine.stock.entity.CustomerUpgrade;
import org.sixtynine.stock.service.CustomerUpgradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Thilan
 * 
 */

@Service
public class CustomerUpgradeServiceImpl implements CustomerUpgradeService {

	@Autowired
	private CustomerUpgradeDao customerUpgradeDao;

	@Override
	public CustomerUpgrade findById(int id) {
		return customerUpgradeDao.findById(id);
	}

	@Override
	@Transactional(readOnly = false)
	public void saveCustomerUpgrade(CustomerUpgrade customerUpgrade) {
		customerUpgradeDao.saveCustomerUpgrade(customerUpgrade);
	}

	@Override
	@Transactional(readOnly = false)
	public void deleteCustomerUpgrade(int id) {
		CustomerUpgrade customerUpgrade = customerUpgradeDao.findById(id);
		if (customerUpgrade != null) {
			customerUpgradeDao.delete(customerUpgrade);
		}
	}

	@Override
	public CustomerUpgrade searchCustomerUpgrade(String orderId) {
		return customerUpgradeDao.searchCustomerUpgrade(orderId);
	}

	@Override
	public List<CustomerUpgrade> searchCustomerUpgrade(int packageDataId) {
		return customerUpgradeDao.searchCustomerUpgrade(packageDataId);
	}

	@Override
	public Page<CustomerUpgrade> searchCustomerUpgrade(int packageId,
			Date fromDate, Date toDate, String orderBy, GridPramDTO gridPramDTO) {
		return customerUpgradeDao.searchCustomerUpgrade(packageId, fromDate,
				toDate, orderBy, gridPramDTO);
	}

}
